from google.appengine.api import users
from table import Candidate
import datetime

def unquote_html (content):
    return content.replace ("&lt;", "<").replace ("&gt;", ">").replace("&amp;", "&");

def get_candidate ():
    user = users.get_current_user()
    cand = Candidate.all().filter('email =',user.email().lower()).get()
    return cand


def get_cand_time_status (cand):
    """
    -1 -- > Test hasn't started
    0  -- > Test has started
    1  -- > Test has ended 
    """
    
    if cand.test_start_time > datetime.datetime(2008,10,11).today():
        return -1
    elif datetime.datetime(2008,10,11).today() > cand.test_end_time:
        return 1
    else:
        return 0
       
